/**
 * Copyright (c) 2014 zhenrongbao.com, Inc. All Rights Reserved
 * @author: jiangshuguang
 * @Date  : 14-12-15
 * @Time  : 下午11:17
 * @brief :
 */
var createUi = require('wap_common:widget/ui/base/base.js').createUi;

exports.Tip = createUi({
    _data:{
        close:true, //是否点击关闭
        onClick:function(){},
        content:'' //tip的内容
    },

    _create:function(){
        var $root = $('' +
            '<div class="ui-tip">' +
            '<div class="tip-wrap">' +
            '<i class="close"></i>' +
            '<div class="tip-content">'+this.data('content')+'</div>' +
            '</div>' +
            '</div>' +
            '').appendTo('body');
        this.data('close') || $root.find('.close').hide();
        this.data({
            "$root":$root
        });
    },

    _init:function(){
        var $root = this.data('$root'),
            me = this;
        $root.on('touchstart',function(e){
//            e.stopPropagation();
//            e.preventDefault();
            me.trigger('click');
            me.data('close') && $root.hide();
        }).on('click',function(){

            })
    },


    hide:function(){
        this.data('$root').hide();
    },

    show:function(content){
        var $root = this.data('$root');
        $root.show();
        content && $root.find('.tip-content').html(content);
    },


    position:function(position){
        this.data('$root').find('.tip-wrap').css(position);
    }
});